package com.xjoyt.pay.master.po;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 提现
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_cash")
public class Cash {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "cash_id", length = 36)
	public String id;

	/**
	 * 提现明细
	 */
	@OneToMany(targetEntity = CashDetail.class, cascade = { CascadeType.REMOVE })
	@JoinColumn(name = "cash_id", foreignKey = @ForeignKey(name = "none"))
	public List<CashDetail> details;

	/**
	 * 流水号
	 */
	@Column(name = "`no`", length = 50)
	public String no;

	/**
	 * 商户流水号
	 */
	@Column(name = "out_trade_no", length = 255)
	public String outTradeNo;

	/**
	 * 金额(分)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 商户
	 */
	@ManyToOne(targetEntity = Merchant.class, cascade = {})
	@JoinColumn(name = "merchant_id", foreignKey = @ForeignKey(name = "none"))
	public Merchant merchant;

	/**
	 * 商户名称
	 */
	@Column(name = "merchant_name", length = 50)
	public String merchantName;

	/**
	 * 商户号
	 */
	@Column(name = "merchant_no", length = 50)
	public String merchantNo;

	/**
	 * 审核状态(true：审核成功，false：审核失败)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_check")
	public Boolean check;
	
	/**
	 * 下单日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;
}
